import React from 'react'

import Child from './child.js'

export default class Propscon extends React.Component{
    constructor(){
        super()
        this.state={
            toson:'来自父组件的信息----father',
            froms:'可改变信息',
            num:0
        }
    }
    
    fromSon=(val)=>{
      this.setState({
          froms:val,
          num:this.state.num+1
      })
    }
    render(){
        let {toson,froms,num} =this.state
        return <>
            <h2>+++++++++++  PROPS 父子组件通信与回调</h2>
            <div>
                <p>父组件------------------</p>
                <p> 可被子组件修改的信息》》》：<span style={{color:'#254695'}}>{froms}</span>----<span  style={{color:'#007899'}}>{num}</span></p>

            </div>
            <p style={{borderTop:"1px solid red"}}>******************子组件*********************</p>
            <Child toson={toson} fromSon={this.fromSon}></Child>
        </>
    }
}